                            <? 
                                $frmtime = time();
                                $print_view = (isset($printview) && $printview == 1) ? true : false; 
                            ?>
                            <div class="main" style="position: relative;">
                                <? if(!$print_view) { ?>
                                
                                <h3 class="title"><?=$clabel?> &raquo; <?=$mlabel?></h3>
                                <?}?>
                                
                                <div class="formdiv">
                                    <form method="POST" id="frmPrintReceipt<?=$frmtime?>">
                                        <table border="0" style="line-height: 14px;">
                                            <? if( isset($errors) ) {
                                               foreach($errors as $error) {
                                               ?>
                                            <tr>
                                                <td class="errormsg" colspan="3">
                                                    <?=$error?>    
                                                </td>
                                            </tr>   
                                               <? 
                                               } 
                                            }  ?>
                                            <? if( isset($successes) ) {
                                               foreach($successes as $success) {
                                               ?>
                                            <tr>
                                                <td class="successmsg" colspan="3">
                                                    <?=$success?>    
                                                </td>
                                            </tr>   
                                               <? 
                                               } 
                                            }  ?>
                                            <?
                                                if($print_view) {
                                                    $school["colspan"] = 3;
                                                    $this->load->view('template/printhead', $school);
                                                }
                                            ?>
                                            <tr>
                                                <td colspan="3">
                                                    <div style="text-align: center; min-width: 700px; margin-top: -10px; ">
                                                        <label style="font-size: 22px; text-transform: uppercase; text-decoration: underline; font-weight: bold;">Receipt</label>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                    <table width="100%">
                                                        <tr>
                                                            <td style="padding-right: 40px;">
                                                                <label style="padding: 0;">Receipt No:   <?=str_pad($receipt_no,3,"0",STR_PAD_LEFT)?></label>
                                                            </td>
                                                            <td style="padding-right: 40px;">
                                                                
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <label style="padding: 0;">Date:   <?=date("d-m-Y",strtotime( $receipt_date ))?></label>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                    <div style="text-align: center;">
                                                        <table width="100%">
                                                            <tr>
                                                                <td style="width: 33%; text-align: left;">
                                                                    <label style="padding: 0;">Register No:   <?=$receipt_regno?></label>
                                                                </td>
                                                                <td style="width: 33%;">
                                                                    <label style="padding: 0;">Class:   <?=$class_label?></label>
                                                                </td>
                                                                <td style="width: 33%; text-align: right;">
                                                                    <label style="padding: 0;">Term:   <?=$receipt_term_label?></label>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                    <div style="text-align: center; ">
                                                        <table width="100%">
                                                            <tr>
                                                                <td style="padding-right: 40px; text-align: left;">
                                                                    <label style="padding: 0;">Student Name:    <?=$student_name?></label>
                                                                </td>
                                                                <td style="padding-right: 40px;">
                                                                    
                                                                </td>
                                                                <td style="text-align: right;">
                                                                    <label style="padding: 0;">Father's Name:   <?=$student_father_name?></label>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                    <table  width="100%" cellspacing="0" cellpadding="0" class="tbl-receipt">
                                                        <tr class="heading">
                                                            <td width="50px">
                                                                <div style="text-align: center;">
                                                                    <label style="padding: 0;">Si. No.</label>
                                                                </div>
                                                            </td>
                                                            <td width="150px">
                                                                <label style="padding: 0;">Item/Category</label>
                                                            </td>
                                                            <td>
                                                                <div style="text-align: center;">
                                                                    <label style="padding: 0;">Description</label>
                                                                </div>
                                                            </td>
                                                            <td width="100px"><label style="padding: 0; float: right;">Amount (QR)</label></td>
                                                        </tr>
                                                    <?
                                                    $receipt_total = 0.00;
                                                    $fee_item_rows = count($items);
                                                    for($rc=0; $rc< $fee_item_rows; $rc++) {
                                                        $receipt_total = $receipt_total + $items[$rc]['ri_amount'];
                                                    ?>
                                                    <tr>
                                                        <td>
                                                            <div style="text-align: center;">
                                                                <label style="padding: 0;"><?=$rc+1?></label>
                                                            </div>
                                                        </td>
                                                        <td>
                                                            <label style="padding: 0;"><?=$items[$rc]['feetype_label']?></label>
                                                        </td>
                                                        <td>
                                                            <label style="padding: 0;"><?=$items[$rc]['ri_description']?></label>
                                                        </td>
                                                        <td>
                                                            <label style="padding: 0; float: right;"><?=number_format($items[$rc]['ri_amount'],0)?></label>
                                                        </td>
                                                    </tr>
                                                    <?
                                                    }
                                                    $receipt_total = $receipt_total - $receipt_discount;
                                                    $uf_receipt_total = number_format($receipt_total,0,"","");
                                                    $receipt_total =  number_format($receipt_total,0);                                           
                                                    ?>
                                                    <tr>
                                                        <td>
                                                            
                                                        </td>
                                                        <td colspan="2">
                                                            <label style="padding: 0; float: Left;">Comment:</label>
                                                            <label style="padding: 0;"><?=$receipt_comment?></label>
                                                            <label style="padding: 0; float: right;">Discount:</label></td>
                                                        <td>
                                                            <label style="padding: 0; text-align: right; float: right;"><?=number_format($receipt_discount,0)?></label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <div style="text-align: center;">
                                                                <label style="font-size: 18px; padding: 0; font-weight: bold;">Total</label>
                                                            </div>
                                                        </td>
                                                        <td colspan="2">
                                                            <label style="font-size: 14px; padding: 0;">
                                                                <?=CurrencyToWords($uf_receipt_total)?>
                                                            </label>
                                                        </td>
                                                        <td style="font-weight: bold;">
                                                            <label style="font-size: 18px; padding: 0; float: right;">QR. 
                                                            <span style="font-size: 18px; padding: 0; color: #3E3E3E;" id="receipt_total_<?=$frmtime?>"><?=$receipt_total?></span></label>
                                                        </td>
                                                    </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <? if(!$print_view) { ?>
                                        	<tr>
                                        		<td>&nbsp;</td>
                                        		<td colspan="2">
                                                    <span style="float: right;">
                                                    <input class="button" type="button" name="btnPrintReceipt" value="Print" id="btnPrintReceipt" />
                                                    </span>
                                                </td>
                                        	</tr>
                                            <?} else {
                                            ?>
                                            <tr>
                                                <td colspan="3">
                                                    <div style="text-align: center; padding: 60px 0 5px 0;">
                                                        <label style="border-top: 1px solid black;">Authorized Signatory</label>
                                                    </div>
                                                </td>
                                            </tr>                                            
                                            <tr>
                                                <td colspan="3" style="">
                                                    <div style="font-size: 14px; font-family:'Times New Roman', sans-serif, serif; color: gray; border-top: 1px solid black;">
                                                        <div style="float: left; width: 33%;">
                                                            <?=$school['school_name']?><br />
                                                            <?=$school['school_address_1']?>, <?=$school['school_city']?>, <?=$school['school_country']?><br />
                                                            Tel:<?=$school['school_phone']?>
                                                        </div>
                                                        <div style="float: left; width: 33%; text-align: center;">
                                                            Email:<?=$school['school_email']?>  
                                                        </div>
                                                        <div style="float: right; width: 33%; text-align: right;">                                                            
                                                            Website:<?=$school['school_website']?>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <?    
                                            }?>
                                        </table>
                                	</form>
                                    <? if(!$print_view) { ?>
                                    <script language="javascript" type="text/javascript">
                                        if(typeof jQuery == 'undefined') {
                                            alert('Invalid Request');
                                            window.location = "/";
                                        }
                                        $(document).ready( function() {
                                            $("#frmPrintReceipt<?=$frmtime?> #btnPrintReceipt").click(function() {
                                               newwindow=window.open("/fees/viewreceipt/<?=$receipt_no?>/print",'name','height=700,width=1000,location=no');
                                               if (window.focus) {newwindow.focus()} 
                                               return false;
                                            });
                                        });
                                        
                                    </script>
                                    <?}?>
                                 </div>
                            </div>